<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      div {
        float: left;
        height: 100px;
        line-height: 100px;
      }
      #d1,
      #d3 {
        background-color: #ccff00;
      }
      #d2 {
        cursor: pointer;
        background-color: #ffcc00;
      }
      #d1 {
        width: 70px;
        overflow: hidden;
        transition: all 0.5s linear;
      }
    </style>
    <script>
      window.onload = function () {
        var d1 = document.getElementById("d1");
        var d2 = document.getElementById("d2");
        var d3 = document.getElementById("d3");
        var open = true;
        d2.onclick = function () {
          if (open) {
            d1.style.width = "0px";
            d2.innerHTML = "<div>&gt;&gt;</div>";
          } else {
            d1.style.width = "70px";
            d2.innerHTML = " <div>&lt;&lt;</div>";
          }
          open = !open;
        };
      };
    </script>
  </head>
  <body>
    <div id="d1">树形列表</div>
    <div id="d2">&gt;&gt;</div>
    <div id="d3">内容主体</div>
  </body>
</html>
